#include<iostream>
#include<string>
using namespace std;
int t;
int gg=1;

void solve(){
    int n,m;
    cin>>n>>m;
    string s,f;
    cin>>s;
    cin>>f;
	string ans;
    cin>>ans;
    
    int step=(int)(f[0]-s[0]);
//    cout<<step<<endl; 
    
    for(int i=0;i<n;i++){
        if((ans[i]-step)<'A')ans[i]+=26;
        ans[i]-=step;
    }
    cout<<"Case #"<<gg<<": "<<ans<<endl;
    return;
}

int main(){
    
    cin>>t;
    while(t--){
        solve();
        gg++;
    }
    return 0;
}
